﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using HR.Appointments.Service.ValueObjects;

namespace HR.Appointments.Service.Test
{
    [TestFixture]
    public class TestOrders
    {
        [SetUp]
        public void SetUp()
        {
            MockDao.SetUp();
        }

        [TearDown]
        public void TearDown()
        {
            MockDao.TearDown();
        }

        [Test]
        public void MockLoad()
        {
            var orders = DAO.Instance.Order.GetByDate(1, DateTime.Parse("28.4.2008"));
            Assert.IsNotNull(orders);
            Assert.AreEqual(3, orders.Count);

            Assert.AreEqual(TestVariables.Date, orders[0].BookingDate);
            Assert.AreEqual(60, orders[0].Duration);
            Assert.AreEqual(TimeUnit.Create(14, 0), orders[0].FromTime);
            Assert.AreEqual(OrderStatus.CONFIRMED, orders[0].Status);
            Assert.AreEqual(false, orders[0].IsSent)    ;
            Assert.AreEqual(Customer.Create("Steinar", "8203047", ""), orders[0].Person);
            Assert.AreEqual(WorkstationEntity.Create(1, "Lára"), orders[0].Station);

            Assert.AreEqual(TestVariables.Date, orders[1].BookingDate);
            Assert.AreEqual(60, orders[1].Duration);
            Assert.AreEqual(OrderStatus.CONFIRMED, orders[1].Status);
            Assert.AreEqual(TimeUnit.Create(11, 0), orders[1].FromTime);
            Assert.AreEqual(false, orders[1].IsSent);

            Assert.AreEqual(TestVariables.Date, orders[2].BookingDate);
            Assert.AreEqual(60, orders[2].Duration);
            Assert.AreEqual(OrderStatus.UNCONFIRMED, orders[2].Status);
            Assert.AreEqual(TimeUnit.Create(15, 0), orders[2].FromTime);
            Assert.AreEqual(false, orders[2].IsSent);
        }

        [Test]
        public void GetBookedTimeSlots()
        {
            var orders = DAO.Instance.Order.GetByDate(1, DateTime.Parse("28.4.2008"));
            Assert.IsNotNull(orders);
            Assert.AreEqual(3, orders.Count);

            Assert.AreEqual(TimeUnit.Create(14, 0), orders[0].FromTime);
            Assert.AreEqual(TimeUnit.Create(15, 0), orders[0].ToTime);

            Assert.AreEqual(TimeUnit.Create(11, 0), orders[1].FromTime);
            Assert.AreEqual(TimeUnit.Create(12, 0), orders[1].ToTime);

            Assert.AreEqual(TimeUnit.Create(15, 0), orders[2].FromTime);
            Assert.AreEqual(TimeUnit.Create(16, 0), orders[2].ToTime);
        }
    }
}
